from datetime import datetime

# 创建一个datetime对象
datetime1 = datetime(2019, 10, 1, 20, 19, 30)  # 2019-10-01 20:19:30
print(datetime1)

# 当前系统时间的datetime
dt2 = datetime.now();
print(dt2)  # 2025-09-21 22:30:18.847477
print(dt2.timetuple())
# time.struct_time(tm_year=2025, tm_mon=9, tm_mday=21, tm_hour=22, tm_min=32, tm_sec=56, tm_wday=6, tm_yday=264, tm_isdst=-1)
print(dt2.timetuple().tm_mon)  # 9

# 得到国际标准时区的时间 ，过期方法
print(dt2.utcnow())  # 2025-09-21 14:33:45.168526

print(dt2.ctime())  # 欧美时间 Sun Sep 21 22:34:40 2025

# 得到datetime的时间戳
print(dt2.timestamp())  # 1758465280.454507 时间戳
# 根据时间戳得到时间
print(dt2.fromtimestamp(1758465280.454507))  # 2025-09-21 22:34:40.454507
